package com.ehome.poct.core.api.mapping;

import cn.hutool.json.JSONUtil;
import com.ehome.poct.core.api.dto.check.AlgoLocalDataDTO;
import com.ehome.poct.core.api.dto.check.CellCheckDataDTO;
import com.ehome.poct.core.api.dto.check.gold.TestStripPriceVO;
import com.ehome.poct.core.api.dto.check.project.EhomeProjectDTO;
import com.ehome.poct.core.api.dto.checkdata.BldCheckDataDTO;
import com.ehome.poct.core.api.vo.check.CellCheckDataVO;
import com.ehome.poct.core.api.vo.check.PoctTypeVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * 转换器
 *
 * @author cq
 * @date 2022/03/16
 **/
@Mapper(componentModel = "spring", imports = {JSONUtil.class})
public interface CheckDataMapping {
    /**
     * 血常规检测数据DTO 转 VO
     * @param cellDTO
     * @return
     */
    @Mappings({
    @Mapping(source = "id",target = "dataId"),
    @Mapping(source = "clinicId",target = "termClinicId"),
    @Mapping(source = "status",target = "checkStatus"),
    @Mapping(source = "filePath",target = "ossFileId"),
    @Mapping(source = "result",target = "checkResult"),
    @Mapping(source = "deviceSno",target = "sno"),
    @Mapping(source = "boardSno",target = "boardId"),
    @Mapping(source = "chart",target = "checkResultChatData"),
    @Mapping(source = "checkResultImgs",target = "checkResultImgs"),
    @Mapping(source = "reqId",target = "algoReqId")
    })
    CellCheckDataVO to(CellCheckDataDTO cellDTO);
    @Mappings({
            @Mapping(target = "termClinicId", source = "clinicId"),
            @Mapping(target = "algoReqId", source = "id"),
            @Mapping(target = "sno", source = "deviceId"),
            @Mapping(target = "boardId", source = "boardSno"),
            @Mapping(target = "checkStatus", constant = "2"),
            @Mapping(target = "ossFileId", expression = "java(algo.getBucketName() + \"/\" + algo.getOssZipPath())"),
            @Mapping(target = "checkResult", expression = "java(JSONUtil.toJsonStr(algo.getResults()))"),
            @Mapping(target = "checkResultChatData", expression = "java(JSONUtil.toJsonStr(algo.getCharts()))"),
            @Mapping(target = "checkResultImgs", expression = "java(JSONUtil.toJsonStr(algo.getImages()))")
    })
    BldCheckDataDTO toBld(AlgoLocalDataDTO algo);


    @Mapping(target = "typeCode",source = "code")
    @Mapping(target = "name",source = "name")
    @Mapping(target = "imgUrl",source = "imgUrl")
    PoctTypeVO toPoctType(EhomeProjectDTO dto);

    List<PoctTypeVO> toPoctTypes(List<EhomeProjectDTO> dto);

    @Mapping(target = "typeCode",source = "code")

    TestStripPriceVO toStripPrice(EhomeProjectDTO dto);

    List<TestStripPriceVO> toStripPrices(List<EhomeProjectDTO> dto);



}
